Skip to content

federation/composition: fix coercion rules when we expand supergraphs#8770

Merged
briannafugate408 merged 9 commits intodevfrom
FED-773
Jan 20, 2026
Merged

federation/composition: fix coercion rules when we expand supergraphs#8770
briannafugate408 merged 9 commits intodevfrom
FED-773

Conversation

@briannafugate408
Copy link
Copy Markdown
Contributor

@briannafugate408 briannafugate408 commented Dec 17, 2025

This PR fixes value coercion during subgraph schema expansion. Previously, directive argument values and field argument defaults were not being properly coerced after directive definitions were expanded, leading to validation failures for schemas that relied on type coercion rules.

When a subgraph schema uses shorthand syntax like @key(fields: ["id"]) (a single-element list where a String is expected), the schema would fail validation because the coercion from ["id"] → "id" wasn't happening during the expansion phase.

  • Added coerce_schema_values() which runs after directive definitions are expanded in expand_schema(). This function coerces:
    • Directive argument values on object types and fields
    • Field argument default values on object and interface types
    • Input field default values on input object types
    • Directive definition argument defaults

Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Performance impact assessed and acceptable
  • Tests added and passing1
    • Manual tests, as necessary

Exceptions

Note any exceptions here

Notes

Footnotes

  1. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@apollo-librarian
Copy link
Copy Markdown
Contributor

apollo-librarian bot commented Dec 17, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 40c39aa2fd4e059fd7252e61
Build Logs: View logs

@github-actions
Copy link
Copy Markdown
Contributor

@briannafugate408, please consider creating a changeset entry in /.changesets/. These instructions describe the process and tooling.

@duckki duckki changed the title fix coercion rules when we expand supergraphs federation/composition: fix coercion rules when we expand supergraphs Jan 9, 2026
@briannafugate408 briannafugate408 force-pushed the FED-773 branch 2 times, most recently from f29acd4 to a55cc87 Compare January 15, 2026 19:57
@briannafugate408 briannafugate408 marked this pull request as ready for review January 16, 2026 17:47
@briannafugate408 briannafugate408 requested review from a team as code owners January 16, 2026 17:47
@briannafugate408 briannafugate408 self-assigned this Jan 16, 2026
Comment thread apollo-federation/src/subgraph/typestate.rs Outdated
Comment thread apollo-federation/src/compat.rs Outdated
Comment thread apollo-federation/tests/composition/compose_directive.rs
Comment thread apollo-federation/tests/subgraph/coercion_tests.rs Outdated
Copy link
Copy Markdown
Contributor

@duckki duckki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor suggestions.

…rge strategies and compose directive tests to be valid even before coercion, update comment about scalar to list coercion, and call coercion in parse to prevent calling multiple times from expand_schema.
@duckki
Copy link
Copy Markdown
Contributor

duckki commented Jan 20, 2026

I just re-ran the failed test.

@briannafugate408 briannafugate408 merged commit 820ae75 into dev Jan 20, 2026
14 of 15 checks passed
@briannafugate408 briannafugate408 deleted the FED-773 branch January 20, 2026 20:53
@duckki duckki mentioned this pull request Jan 29, 2026
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants